<div id="sidebar" class="sidebar">
    <div id="innerSidebar">

        <% if(theUser.loggedIn){ %>
            <div id="panel_user" class="panel">
                <h5><%= __('user_panel') %></h5>
                <div class="panel-content">
                    <div class="comment-text"><%= __('login_as') %> <b><%= theUser.username %></b></div>
                    <br/>
                    <ul>
                        <% if(theUser.groupID == 1){ %>
                            <li><a href="admin.asp"><%= __('administration') %></a></li>
                        <% } %>
                        <% if(theUser.rights["post"] > 1){ %>
                            <li><a href="article.asp?act=new"><%= __('new_article') %></a></li>
                        <% } %>
                        <li><a href="user.asp?act=edit&amp;id=<%= theUser.id %>"><%= __('edit_profile') %></a>
                        </li>
                        <li><a href="login.asp?act=logout"><%= __('logout') %></a></li>
                    </ul>
                </div>
            </div>
        <% }else{ %>
            <div id="panelUser" class="panel" style="display: none">
                <h5><%= __('user_panel') %></h5>
                <div class="panel-content">
                    <div id="loginForm">
                        <form name="login" method="post" action="login.asp?act=login">
                            <input name="_csrf" type="hidden" value="<%- ctx.csrf %>" />
                            <table cellpadding="0" cellspacing="2" width="100%">
                                <tr>
                                    <td align="right"><%= __('username') %>:</td>
                                    <td><input name="username" type="text" size="12" maxlength="24" class="text"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right"><%= __('password') %>:</td>
                                    <td><input name="password" type="password" size="12" maxlength="16"
                                               class="text"/></td>
                                </tr>
                                <% if(theCache.settings["enableSecurityCode"] == 1){ %>
                                    <tr>
                                        <td align="right"><%= __('scode') %>:</td>
                                        <td><input name="scode" size="4" maxlength="4" type="text" class="text"/>
                                            <img src="scode.asp" alt="<%= __('scode') %>"/>
                                        </td>
                                    </tr>
                                <% } %>
                                <tr>
                                    <td align="center">
                                        <% if(theCache.settings["enableRegister"] == 1){ %>
                                            <a href="register.asp"
                                               style="text-decoration: underline; color: #666666;"><%= __('reg_now') %></a>
                                        <% } %>
                                    </td>
                                    <td>
                                        <input name="Login" type="submit" value="  <%= __('login') %>  "
                                               class="button"/>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        <% } %>

        <div id="panelCategory" class="panel">
            <h5><%= __('categories') %></h5>
            <div class="panel-content">
                <ul>
                    <li><a href="default.asp"><b><%= __('index') %></b></a></li>
                    <% for(var i = 0;i < theCache.categories.length;i++){

                    if(!theCache.categories[i].hidden || (theCache.categories[i].hidden && theUser.rights["view"] > 1)){
                    %>
                        <li><a href="default.asp?cat=<%= theCache.categories[i].id %>"><%= helper.HTMLEncodeLite(theCache.categories[i].name) %></a>
                            [<%= theCache.categories[i].articleCount %>] <a href="feed.asp?cat=<%= theCache.categories[i].id %>" title="<%= helper.HTMLEncodeLite(theCache.categories[i].name) %> <%= __('rss_feed') %>" target="_blank"><img
                                        src="/public/<%= theCache.settings["imageFolder"] %>/rss.png" class="meta-button"
                                        alt="<%= helper.HTMLEncodeLite(theCache.categories[i].name) %> <%= __('rss_feed') %>"/></a>
                            <% if(theCache.categories[i].locked){ %>
                                <img src="/public/<%= theCache.settings["imageFolder"] %>/icon_lock.gif"
                                     alt="<%= __('locked') %>"/>
                            <% } %>
                        </li>
                    <%

                    }
                    } %>
                </ul>
            </div>
        </div>

        <div id="panelCalendar" class="panel">
            <h5><%= __('calendar') %></h5>
            <%- theCache.calendarHTML %>
        </div>

        <div id="panelArticle" class="panel">
            <h5><%= __('recent_articles') %></h5>
            <div class="panel-content">
                <ul>
                    <% var j = 0;
                    for(var i = 0;i < theCache.recentArticles.length && j <
                            theCache.settings["recentArticleList"];i++){
                            with(theCache.recentArticles[i]){
                        var objArticle = new Object();
                        objArticle.mode = theCache.recentArticles[i].log_mode;
                        objArticle.authorID = theCache.recentArticles[i].log_authorid;
                        objArticle.category = theCache.getCategoryByID(theCache.recentArticles[i].log_catid);
                    if(theUser.checkViewPermission(objArticle)){
                        j++;
                    %>
                    <li><a href="article.asp?id=<%= log_id %>"
                           title="<%= helper.HTMLEncode(log_title) %>"><%= helper.HTMLEncode(
                                    helper.cutString(log_title, 28)) %></a></li>
                    <%
                    }
                    }
                    } %>
                </ul>
            </div>
        </div>

        <div id="panelComment" class="panel">
            <h5><%= __('recent_comments') %></h5>
            <div class="panel-content">
                <ul>
                    <% var j = 0;
                    for(var i = 0;i < theCache.recentComments.length && j <
                            theCache.settings["recentCommentList"];i++){
                            with(theCache.recentComments[i]){
                    if(log_mode == 1 && (hidden || cat_hidden) && theUser.rights["view"] > 1 ||
                            log_mode == 1 && !hidden && !cat_hidden && theUser.rights["view"] > 0 ||
                            log_mode == 2 && !hidden && !cat_hidden && theUser.loggedIn &&
                            theUser.rights["view"] > 0 ||
                            log_mode == 3 && theUser.loggedIn && theUser.rights["view"] > 1 ||
                            log_mode == 4 && theUser.loggedIn && theUser.rights["view"] > 2
                    ){
                        j++;
                    %>
                    <li><a href="article.asp?id=<%= log_id %>#comment<%= id %>"
                           title="<%= author+" ["+helper.HTMLEncode(log_title)+"]: \n"+helper.HTMLEncodeLite(
                                   helper.cutString(helper.trimUBB(content), 300)) %>"><%= helper.HTMLEncodeLite(
                                    helper.cutString(helper.trimUBB(content), 24)) %></a></li>
                    <%
                    }else{
                        j++;
                    %>
                    <li><a href="article.asp?id=<%= log_id %>#comment<%= id %>"
                           title="<%= __('hidden') %>"><%= content.replace(/./g, "*").substr(0, 24) %></a>
                    </li>
                    <%
                    }
                    }
                    } %>
                </ul>
            </div>
        </div>

        <div id="panelSearch" class="panel">
            <h5><%= __('search') %></h5>
            <div class="panel-content">
                <form name="searchForm" method="post" action="" onsubmit="return doSearch();">
                    <input name="_csrf" type="hidden" value="<%- ctx.csrf %>" />
                    <input name="q" type="text" id="q" class="text search-field"/>
                    <select name="searchType">
                        <option value="articles"><%= __('articles') %></option>
                        <option value="comments"><%= __('comments') %></option>
                        <option value="guestbook"><%= __('guestbook') %></option>
                        <option value="trackbacks"><%= __('trackbacks') %></option>
                    </select>
                    <input name="submit" type="submit" id="submit" value=" <%= __('search') %> "
                           class="button"/>
                </form>
            </div>
        </div>

        <div id="panelStats" class="panel">
            <h5><%= __('stats') %></h5>
            <div class="panel-content">
                <%= __('articles') %>: <%= theCache.settings["counterArticle"] %><br/>
                <a href="comment.asp"><%= __('comments') %>
                    : <%= theCache.settings["counterComment"] %></a><br/>
                <a href="trackback.asp?act=list"><%= __('trackbacks') %>
                    : <%= theCache.settings["counterTrackback"] %></a><br/>
                <a href="user.asp"><%= __('reg_users') %>: <%= theCache.settings["counterUser"] %></a><br/>
                <% if(theUser.groupID == 1){ %>
                <a href="stats.asp" target="_blank">
                    <% } %>
                    <%= __('visitors') %>: <%= theCache.settings["counterVisitor"] %>
                    <% if(theUser.groupID == 1){ %>
                </a>
                <% } %>
                <br/>
                <%= __('online_user') %>: <%= //Application(lbsNamespace + "userOnline") %><br/>
                <br/>
                <a href="feed.asp" title="<%= __('articles') %><%= __('rss_feed') %>" target="_blank"><img
                            src="/public/<%= theCache.settings["imageFolder"] %>/rss_article.png" class="meta-button"
                            alt="<%= __('articles') %><%= __('rss_feed') %>"/></a><br/>
                <a href="feed.asp?selected=true" title="<%= __('selected') %><%= __('rss_feed') %>"
                   target="_blank"><img src="/public/<%= theCache.settings["imageFolder"] %>/rss_selected.png"
                                        class="meta-button"
                                        alt="<%= __('selected') %><%= __('rss_feed') %>"/></a><br/>
                <a href="feed.asp?q=comment" title="<%= __('comments') %><%= __('rss_feed') %>"
                   target="_blank"><img src="/public/<%= theCache.settings["imageFolder"] %>/rss_comment.png"
                                        class="meta-button"
                                        alt="<%= __('comments') %><%= __('rss_feed') %>"/></a><br/>
                <a href="http://www.unicode.org/" title="Unicode.org" target="_blank"><img
                            src="/public/<%= theCache.settings["imageFolder"] %>/utf8.png" class="meta-button"
                            alt="Unicode Encoding"/></a><br/>
                <a href="http://creativecommons.org/licenses/by-nc-sa/1.0/" title="Creative Commons Licensed"
                   target="_blank"><img src="/public/<%= theCache.settings["imageFolder"] %>/cc.png" class="meta-button"
                                        alt="Creative Commons Licensed"/></a><br/>
                <a href="http://www.voidland.com/" title="Powered by LBS" target="_blank"><img
                            src="/public/<%= theCache.settings["imageFolder"] %>/lbs.png" class="meta-button"
                            alt="Powered by LBS"/></a><br/>
            </div>
        </div>

        <div id="panelLinks" class="panel">
            <h5><%= __("links") %></h5>
            <div class="panel-content">
                <%- theCache.settings["links"] %>
            </div>
        </div>

    </div>
</div>
